import React from "react";
import qs from "querystring"

const contentList = [
  {id: "01", content: "content 01"},
  {id: "02", content: "content 02"},
  {id: "03", content: "content 03"},
]

export default class Detail extends React.Component {
  render() {
    // params传参接收参数
    // let {id, title} = this.props.match.params

    // search传参接收参数
    // let {id, title} = qs.parse(this.props.location.search.slice(1))

    // state传参接收参数
    let {id, title} = this.props.location.state

    let res = contentList.find(item => item.id === id)

    return (
        <div>
          <p>id :{id}</p>
          <p>title :{title}</p>
          <p>content: {res.content}</p>
        </div>
    )
  }
}